﻿/*
 *********************************************************************
 *    Management Extensions for Windows Windows Server AppFabric     *
 *********************************************************************
 *    Author    : Fatih Boy [fatih@enterprisecoding.com]             *
 *    Web site  : http://www.enterprisecoding.com                    *
 *********************************************************************
 *    License   : GNU Library General Public License (LGPL)          * 
 *********************************************************************
 */

using System;
using Microsoft.Web.Management.Client.Win32;

using Com.Enterprisecoding.AppFabric.Extensions.Client.Resources.Cache;

namespace Com.Enterprisecoding.AppFabric.Extensions.Client.Pages.Cache.Accounts {
    internal partial class Account2Add : DialogForm {
        #region Properties
        public string AccountName { get { return accountName.Text; } }
        public bool Force { get { return force.Checked; } } 
        #endregion

        public Account2Add(IServiceProvider serviceProvider)
            : base(serviceProvider) {
            InitializeComponent();

            Text = Resources.Cache.CacheAccountsPage.Account2Add_Title;

            add.Text = Resources.Cache.CacheAccountsPage.Account2Add_Add;
            cancel.Text = Resources.Cache.CacheAccountsPage.Account2Add_Cancel;
            label.Text = Resources.Cache.CacheAccountsPage.Account2Add_Label;
            force.Text = Resources.Cache.CacheAccountsPage.Account2Add_Force;
            selectAccount.Text = Resources.Cache.CacheAccountsPage.Account2Add_Select;
        }

        private void accountName_TextChanged(object sender, System.EventArgs e) {
            add.Enabled = !string.IsNullOrEmpty(accountName.Text) && accountName.Text.Trim().Length > 0;
        }

        protected override bool CanShowHelp {
            get { return false; }
        }

        protected override void ShowHelp() {
            //todo : implement show help
            base.ShowHelp();
        }

        private void selectAccount_Click(object sender, EventArgs e) {
            var wrapper = new ObjectPicker.ObjectPicker();
            if (wrapper.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) {
                accountName.Text = wrapper.Selections[0].Name;
            }
        }
    }
}